//
//  JSMCommentTableViewCell.m
//  TakeYouTourTogether
//
//  Created by dllo on 15/12/5.
//  Copyright © 2015年 king. All rights reserved.
//

#import "JSMCommentTableViewCell.h"

@implementation JSMCommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView {
    self.userImageView = [[BaseImageView alloc] init];
    [self.contentView addSubview:self.userImageView];
    
    self.userImageView.layer.borderWidth = 1;
    self.userImageView.layer.masksToBounds = YES;
    
    self.userIfoNameLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.userIfoNameLabel];
    
    self.userIfoNameLabel.textAlignment = NSTextAlignmentRight;
    self.userIfoNameLabel.font = [UIFont systemFontOfSize:13];
    self.userIfoNameLabel.textColor = [UIColor colorWithRed:0.704 green:0.715 blue:0.728 alpha:0.960];
    
    self.titleLabel = [[BaseLabel alloc] init];
    [self.contentView addSubview:self.titleLabel];
    
    self.titleLabel.font = [UIFont systemFontOfSize:15];
    self.titleLabel.numberOfLines = 0;
    [self.titleLabel sizeToFit];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.userImageView.frame = CGRectMake(15, 5, TableViewCellWidth / 10, TableViewCellWidth / 10);
    self.userImageView.layer.cornerRadius = self.userImageView.frame.size.height / 2;
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName,nil];
    CGRect wordRect = [self.titleLabel.text boundingRectWithSize:CGSizeMake(TableViewCellWidth - 30 - self.userImageView.frame.size.width, 15) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.titleLabel.frame = CGRectMake(15 + self.userImageView.frame.size.width, 5, TableViewCellWidth - 30 - self.userImageView.frame.size.width, wordRect.size.height);
    self.userIfoNameLabel.frame = CGRectMake(15, 5 + self.titleLabel.frame.size.height, TableViewCellWidth - 30, self.userImageView.frame.size.height / 2);
}


@end
